home *** CD-ROM | disk | FTP | other *** search
/ Hottest 6 / Hottest 6 (1996)(PDSoft)[!].iso / software / programming / c / sipp / demo / torustest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1978-11-24  |  1.7 KB  |  88 lines

  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. #include <sipp.h>
  5. #include <primitives.h>
  6.  
  7.  
  8.  
  9. #define SMALLRES 15
  10. #define BIGRES   40
  11.  
  12. extern char *optarg;
  13.  
  14. main(argc, argv)
  15.     int    argc;
  16.     char **argv;
  17. {
  18.     FILE    *fp ;
  19.     Surf_desc surf;
  20.  
  21.     char    *imfile_name;
  22.     int      mode;
  23.     int      c;
  24.     int      size;
  25.  
  26.     imfile_name = "torus.ppm";
  27.     mode = PHONG;
  28.     size = 256;
  29.  
  30.     while ((c = getopt(argc, argv, "pgfls:")) != EOF) {
  31.         switch (c) {
  32.           case 'p':
  33.             mode = PHONG;
  34.             imfile_name = "torus.ppm";
  35.             break;
  36.  
  37.           case 'g':
  38.             mode = GOURAUD;
  39.             imfile_name = "torus.ppm";
  40.             break;
  41.  
  42.           case 'f':
  43.             mode = FLAT;
  44.             imfile_name = "torus.ppm";
  45.             break;
  46.  
  47.           case 'l':
  48.             mode = LINE;
  49.             imfile_name = "torus.pbm";
  50.             break;
  51.  
  52.           case 's':
  53.             size = atoi(optarg);
  54.             break;
  55.         }
  56.     }
  57.  
  58.     sipp_init();
  59.  
  60.     lightsource_create( 1.0,  1.0, 1.0,  0.9, 0.9, 0.9,  LIGHT_DIRECTION);
  61.     lightsource_create(-1.0, -1.0, 0.5,  0.4, 0.4, 0.4,  LIGHT_DIRECTION);
  62.  
  63.     surf.ambient = 0.5;
  64.     surf.specular = 0.6;
  65.     surf.c3 = 0.2;
  66.     surf.color.red = 0.6;
  67.     surf.color.grn = 0.3;
  68.     surf.color.blu = 0.5;
  69.     surf.opacity.red = 1.0;
  70.     surf.opacity.grn = 1.0;
  71.     surf.opacity.blu = 1.0;
  72.     
  73.     object_add_subobj(sipp_world, sipp_torus(1.0, 0.4, BIGRES, SMALLRES, &surf,
  74.                               basic_shader, WORLD)); 
  75.  
  76.     camera_params(sipp_camera, 4.0, 0.0, 4.5,  0.5, 0.0, 0.0,  
  77.                   0.0, 0.0, 1.0,  0.4);
  78.  
  79.     printf("Rendering, wait...");
  80.     fflush(stdout);
  81.  
  82.     fp = fopen(imfile_name, "w");
  83.     render_image_file(size, size, fp, mode, 2);
  84.     printf("Done.\n");
  85.  
  86.     exit(0);
  87. }
  88.